const Router = require('koa-router')
const router = new Router({ prefix: "/api/goods" })
const { auth, hadAdminPermission } = require('../middleware/auth.middleware')
const { upload, create, update, remove1, renew, findAllGoods,findGoodsById } = require('../controller/good.controller')
const { validator } = require('../middleware/goods.middleware')

// 物品上传路由

// 发布商品上传接口
//router.post('/',auth,hadAdminPermission,validator,create)
router.post("/add",auth, validator, create)
router.post("/upload",auth, upload);
// 修改商品信息
router.put('/:id',auth, validator, update)
// 商品下架（软删除）
router.post('/:id/off', remove1)
// 商品上架（软恢复）
router.post('/:id/on', renew)
// 商品列表
router.get('/', findAllGoods)
router.get('/:id', findGoodsById)
module.exports = router
